package com.pureut.storage.controller;

import cn.dev33.satoken.annotation.SaCheckPermission;
import com.pureut.storage.dto.IncomingMaterialPrintingDetailDto;
import com.pureut.storage.service.IncomingMaterialPrintingDetailService;
import com.pureut.storage.vo.DeleteDetailVo;
import com.pureut.storage.vo.IncomingMaterialPrintingVo;
import com.pureut.storage.vo.IncomingMaterialSubcontractPrintingVo;
import com.sale.common.core.domain.R;
import com.sale.common.core.web.controller.BaseController;
import com.sale.common.log.annotation.Log;
import com.sale.common.log.enums.BusinessType;
import com.sale.common.mybatis.core.page.PageQuery;
import com.sale.common.mybatis.core.page.TableDataInfo;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/***
 * 采购打印明细控制层
 * Author:C
 * Date:2023/01/16 15:25
 * @DESC
 */
@RestController
@RequestMapping("/incoming-material-printing-detail")
public class IncomingMaterialPrintingDetailController extends BaseController {

    @Resource
    IncomingMaterialPrintingDetailService incomingMaterialPrintingDetailService;

    /**
     * 来料打印明细列表
     */
    @GetMapping("/list")
    public TableDataInfo<IncomingMaterialPrintingDetailDto> getList(long id, PageQuery pageQuery) throws Exception {
        //查询采购打印明细列表
        return incomingMaterialPrintingDetailService.getDetailList(id,pageQuery);
    }

    /**
     * 采购打印
     */
    //@SaCheckPermission("warehouse:incomingPrint:cgPrint:print")
    @PostMapping("/print")
    @Log(title = "采购打印", businessType = BusinessType.INSERT)
    public R<List<IncomingMaterialPrintingDetailDto>> print(@RequestBody IncomingMaterialPrintingVo incomingMaterialPrintingVo) throws Exception {
        return R.ok(incomingMaterialPrintingDetailService.getPrint(incomingMaterialPrintingVo));
    }

    /**
     * 委外打印
     */
//    @SaCheckPermission("warehouse:incomingPrint:cgPrint:print")
    @PostMapping("/subcontractPrint")
    @Log(title = "委外打印", businessType = BusinessType.INSERT)
    public R<List<IncomingMaterialPrintingDetailDto>> subcontractPrint(@RequestBody IncomingMaterialPrintingVo incomingMaterialPrintingVo) throws Exception {
        return R.ok(incomingMaterialPrintingDetailService.subcontractPrint(incomingMaterialPrintingVo));
    }

    /**
     * 完工打印
     */
//    @SaCheckPermission("warehouse:incomingPrint:cgPrint:print")
    @PostMapping("/wipCompletionPrint")
    @Log(title = "完工打印", businessType = BusinessType.INSERT)
    public R<List<IncomingMaterialPrintingDetailDto>> wipCompletionPrint(@RequestBody IncomingMaterialPrintingVo incomingMaterialPrintingVo) throws Exception {
        return R.ok(incomingMaterialPrintingDetailService.wipCompletionPrint(incomingMaterialPrintingVo));
    }

//    /**
//     * 来料打印页面对应的号码全部删除，上表的打印状态更新为“已完成”(fegin调用)
//     */
//    @PostMapping("/deleteDetail")
//    @Log(title = "来料打印页面对应的号码全部删除，上表的打印状态更新为“已完成”", businessType = BusinessType.DELETE)
//    public AjaxResult deleteDetail(@RequestBody DeleteDetailVo deleteDetailVo) {
//        return toAjax(incomingMaterialPrintingDetailService.deleteDetail(deleteDetailVo));
//    }
//
//    /**
//     * 删除来料打印页面数据（fegin调用）
//     */
//    @PostMapping("/deleteData")
//    @Log(title = "删除来料打印页面数据（fegin调用）", businessType = BusinessType.DELETE)
//    public AjaxResult deleteData(@RequestBody DeleteDetailVo deleteDetailVo) {
//        return toAjax(incomingMaterialPrintingDetailService.deleteData(deleteDetailVo));
//    }

}
